package com.downbox.repository;

import com.downbox.domain.DrawHistory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 抽奖历史仓库接口
 */
@Repository
public interface DrawHistoryRepository extends JpaRepository<DrawHistory, Long> {
    /**
     * 根据用户ID查询抽奖历史，按创建时间倒序
     */
    Page<DrawHistory> findByUidOrderByCreatedAtDesc(Long uid, Pageable pageable);

    /**
     * 根据用户ID和类型查询抽奖历史
     */
    Page<DrawHistory> findByUidAndTypeOrderByCreatedAtDesc(Long uid, String type, Pageable pageable);

    /**
     * 统计用户抽奖总数
     */
    long countByUid(Long uid);
}